/*******************************************************************************
 * Copyright (c) 2001, 2004 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package com.trainfinder.datapersistace;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.cfg.Environment;

public class BeanSessionFactory {

	private static final SessionFactory SESSION_FACTORY = newSessionFactory();

	public static final SessionFactory newSessionFactory() {

		Class[] classes = new Class[] { Journey.class };

		AnnotationConfiguration cfg = new AnnotationConfiguration();
 
//		-- cfg.setProperty(Environment.HBM2DDL_AUTO, "create-drop");
 	cfg.setProperty(Environment.HBM2DDL_AUTO, "update");

		for (int i = 0; i < classes.length; i++) {
			cfg.addAnnotatedClass(classes[i]);
		}
		// Dialect dialect = Dialect.getDialect();
		return cfg.buildSessionFactory();
	}

	public static final Session getSession() {
		return SESSION_FACTORY.openSession();
	}

}
